package com.liuyjy.test.domain.xml.lecturer.req;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @Author liuyjy
 * @Date 2024/12/26 16:37
 * @Description: 授课记录
 **/
@XmlAccessorType(XmlAccessType.FIELD)
@Data
public class LecturerCostRequestItem {

    /**
     * 讲师工号
     */
    @XmlElement(name = "lecturerCode")
    private String lecturerCode;

    /**
     * 讲师姓名
     */
    @XmlElement(name = "lecturerName")
    private String lecturerName;

    /**
     * 所属组织机构
     */
    @XmlElement(name = "businessOrg")
    private String businessOrg;

    /**
     * 发薪地
     */
    @XmlElement(name = "payrollPlace")
    private String payrollPlace;

    /**
     * 课程名称
     */
    @XmlElement(name = "courseName")
    private String courseName;

    /**
     * 授课费用类型: 0.在线 1.面授 2.课程开发 3.作业员如模培训 4.其他
     */
    @XmlElement(name = "courseType")
    private String courseType;
    /**
     * 课程开发时间
     */
    @XmlElement(name = "exploitPeriod")
    private String exploitPeriod;
    /**
     * 授课时长
     */
    @XmlElement(name = "exploitDuration")
    private String exploitDuration;
    /**
     * 参与人数
     */
    @XmlElement(name = "joinNum")
    private String joinNum;
    /**
     * 满意度
     */
    @XmlElement(name = "satisfaction")
    private String satisfaction;
    /**
     * 是否发放费用
     */
    @XmlElement(name = "isGrantCost")
    private String isGrantCost;
    /**
     * 课酬基准
     */
    @XmlElement(name = "rewardCriterion")
    private String rewardCriterion;
    /**
     * 计划课酬
     */
    @XmlElement(name = "planCost")
    private String planCost;

    public void setCourseType(String courseType) {
        switch (courseType) {
            case "0":
                courseType = "在线课";
                break;
            case "1":
                courseType = "面授课";
                break;
            case "2":
                courseType = "课程开发";
                break;
            case "3":
                courseType = "作业员如模培训";
                break;
            case "4":
                courseType = "其他";
                break;
        }
        this.courseType = courseType;
    }

    public void setExploitDuration(String exploitDuration) {
        if (StringUtils.isBlank(exploitDuration)) {
            exploitDuration = "0";
        }
        if (Integer.parseInt(exploitDuration) > 0) {
            exploitDuration = new BigDecimal(exploitDuration)
                    .divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP).toString();
        }
        this.exploitDuration = exploitDuration;
    }
}
